package mq

import (
	"charging_pile/util/protocol/jiuxing"

	"github.com/zeromicro/go-zero/core/logx"
)

// 启动充电结果

func handle21(nc *natsClient, in *jiuxing.Package) (jxMsg *jiuxing.Package) {
	msg := jiuxing.Msg21{}
	msg.Decode(in.Payload)
	logx.Infof("msg21:%+v", msg)

	defer func() {
		resp := jiuxing.Msg22{}
		jxMsg = &jiuxing.Package{
			Cmd:        byte(0x22),
			Sn:         in.Sn,
			Encryption: in.Encryption,
			PackageLen: 0,
			Payload:    []uint8{},
			Check:      0,
		}
		resp.Tm = formatJxTime()
		resp.PlugIdx = msg.PlugIdx
		jxMsg.PackageLen = uint16(len(jxMsg.Payload))
	}()

	return nil
}

func init() {
	HandlerMap[uint8(0x21)] = handle21
}
